/*
 * Copyright (c) 2021 minglong@iscas.ac.cn
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 *    of conditions and the following disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
<template>
  <div class="markdown-body">
    <sig />

    <a-table :columns="columns" :data-source="sigList" >
      <template #url_link="router_link">
        <a :href="'#/SIG/' + router_link.text">{{ router_link.text }}</a>
      </template>

      <template #gitee_pg="page_obj">
        <a :href="page_obj.text">Gitee 链接</a>
      </template>

      <template #mail_ls="mail_obj">
        <a :href="'mailto:' + mail_obj.text">{{ mail_obj.text }}</a>
      </template>
    </a-table>

    <a-button type="primary" class="my-4" @click="send" block>提交申请</a-button>
    <SigApplicationDrawer @register="register4sig" />
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { Card, Table } from 'ant-design-vue';
import { useDrawer } from '/@/components/Drawer';
import sig from './sig/README.md';
import SigApplicationDrawer from './SigApplicationDrawer.vue';
import 'highlight.js/styles/github.css';
import 'github-markdown-css';

const columns = [
  { 
    title: 'SIG 名称', 
    dataIndex: 'SIG名称', 
    key: 'sig_name', 
    width: 200,
    fixed: 'center',
    slots: { customRender: 'url_link' },
  },
  {
    title: 'Gitee 主页',
    dataIndex: 'Gitee主页',
    key: 'gitee_page',
    width: 200,
    slots: { customRender: 'gitee_pg' },
  },
  {
    title: '邮件列表',
    dataIndex: '邮件列表',
    key: 'mail_list',
    width: 350,
    slots: { customRender: 'mail_ls' },
  },
  { title: '状态', dataIndex: '状态', key: 'status', width: 100, fixed: 'right' },
];

interface SigItem {
  key: string;
  SIG名称: string;
  Gitee主页: string;
  邮件列表: string;
  状态: string;
}

const sigList: SigItem[] = [
  {
    key: 'sig-riscv_cn',
    SIG名称: 'sig-riscv_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/riscv',
    邮件列表: 'sig_risc_v@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig_devboard_cn',
    SIG名称: 'sig_devboard_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-devboard',
    邮件列表: 'sig_devboard@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig_openblock_cn',
    SIG名称: 'sig_openblock_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/openblock',
    邮件列表: 'sig_openblock@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig_systemapplications_cn',
    SIG名称: 'sig_systemapplications_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/system_applications',
    邮件列表: 'sig_systemapplication@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig_dllite_micro_cn',
    SIG名称: 'sig_dllite_micro_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/dllite_micro',
    邮件列表: 'sig_risc_v@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig-python_cn',
    SIG名称: 'sig-python_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/python',
    邮件列表: 'sig_python@openharmony.io',
    状态: '已成立',
  },
  {
    key: 'sig_linkboy_cn',
    SIG名称: 'sig_linkboy_cn',
    Gitee主页: 'https://gitee.com/openharmony-sig/linkboy',
    邮件列表: 'sig_linkboy@openharmony.io',
    状态: '已成立',
  },
  // sig_ai_framework_integration_cn
  {
    key: 'sig-ai_framework_integration_cn',
    SIG名称: 'sig-ai_framework_integration_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-ai_framework_integration',
    邮件列表: 'sig-ai_framework_integration@openharmony.io',
    状态: '已成立',
  },
  // sig-infrastructure_cn
  {
    key: 'sig-infrastructure_cn',
    SIG名称: 'sig-infrastructure_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-infrastructure',
    邮件列表: 'sig-infrastructure@openharmony.io',
    状态: '已成立',
  },
  // sig_hilog
  {
    key: 'sig_hilog_cn',
    SIG名称: 'sig_hilog_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-hilog',
    邮件列表: 'NONE',
    状态: '已成立',
  },
  // sig_miniblink
  {
    key: 'sig_miniblink_cn',
    SIG名称: 'sig_miniblink_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-miniblink',
    邮件列表: 'sig_miniblink@openharmony.io',
    状态: '已成立',
  },
  // sig_blockchain
  {
    key: 'sig_blockchain_cn',
    SIG名称: 'sig_blockchain_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-blockchain',
    邮件列表: 'sig_blockchain@openharmony.io',
    状态: '已成立',
  },
  // sig_industrial_internet
  {
    key: 'sig_industrial_internet_cn',
    SIG名称: 'sig_industrial_internet_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-industrial_internet',
    邮件列表: 'sig_industry_network@openharmony.io',
    状态: '已成立',
  },
  // sig_edu_data_specification
  {
    key: 'sig_edu_data_specification_cn',
    SIG名称: 'sig_edu_data_specification_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-edu_data_specification',
    邮件列表: 'sig_edu_data@openharmony.io',
    状态: '已成立',
  },
  // sig_knowledge
  {
    key: 'sig_knowledge_cn',
    SIG名称: 'sig_knowledge_cn',
    Gitee主页: 'https://gitee.com/openharmony/community/tree/master/sig/sig-knowlege',
    邮件列表: 'sig-knowledge@openharmony.io',
    状态: '已成立',
  },
];

export default defineComponent({
  components: {
    ACard: Card,
    ATable: Table,
    sig,
    SigApplicationDrawer,
  },
  setup() {
    const [register4sig, { openDrawer: openDrawer }] = useDrawer();
    function send() {
      openDrawer(true, {
        data: 'content',
        info: 'Info',
      });
    }
    return {
      register4sig,
      send,
    };
  },
  data() {
    return {
      sigList,
      columns,
    };
  },
});
</script>
<style>
.markdown-body {
  box-sizing: border-box;
  min-width: 200px;
  max-width: 980px;
  margin: 0 auto;
  padding: 45px;
}
</style>
